package com.bree.erp.entity;

import java.util.Collection;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

@NamedQueries({
	@NamedQuery(name = BrandSeller.QUERY_SELECT_ALL_BRANDSELLER, 
		query = "SELECT bs FROM BrandSeller bs"),
	@NamedQuery(name = BrandSeller.QUERY_FINDBYNAME_BRANDSELLER, 
		query = "SELECT bs FROM BrandSeller bs WHERE bs.name = :name")
})
@Entity
public class BrandSeller {
	
	public static final String QUERY_SELECT_ALL_BRANDSELLER = "findAllBrandSeller";
	public static final String QUERY_FINDBYNAME_BRANDSELLER = "findBrandSellerByName";

	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE)
	private long id;
	
	private String name;
	
	private String description;
	
	@OneToMany(mappedBy="seller")
	private Collection<MasterItem> brands;
	
	public String getDisplayName() {
		StringBuilder sb = new StringBuilder(name);
		sb.append(" : ").append(description);
		
		return sb.toString();
	}
	
	public void setDisplayName(String noop) {
		
	}

	/**
	 * @return the id
	 */
	public long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the brands
	 */
	public Collection<MasterItem> getBrands() {
		return brands;
	}

	/**
	 * @param brands the brands to set
	 */
	public void setBrands(Collection<MasterItem> brands) {
		this.brands = brands;
	}
}
